Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonobuoy Conformance Results #204

Closed
wants to merge 2 commits into from
Closed

Conversation

VestigeJ
Copy link
Contributor

Proposed Changes

Adding the ability to run sonobuoy and get the results from the run of conformance results

the command to run it exists within the makefile and it has been edited to accommodate the long timeout window that conformance results frequently hit within go/ginkgo expectations.

Types of Changes

It can be a quick test by altering the launchSonobuoyTests("quick") but the default is to run the full conformance suite from upstream. Primarily to be used during patch validation runs but it could be used more frequently in other ways to quickly check a clusters status. Although if you have a cluster running the fastest and easiest way to run conformance is to do it the simple way upstream does it with a simple yaml deployment.

---
apiVersion: v1
kind: Namespace
metadata:
  name: conformance
---
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    component: conformance
  name: conformance-serviceaccount
  namespace: conformance
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    component: conformance
  name: conformance-serviceaccount-role
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: conformance-serviceaccount
subjects:
- kind: ServiceAccount
  name: conformance-serviceaccount
  namespace: conformance
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    component: conformance
  name: conformance-serviceaccount
rules:
- apiGroups:
  - '*'
  resources:
  - '*'
  verbs:
  - '*'
- nonResourceURLs:
  - '/metrics'
  - '/logs'
  - '/logs/*'
  verbs:
  - 'get'
---
apiVersion: v1
kind: Pod
metadata:
  name: e2e-conformance-test
  namespace: conformance
spec:
  containers:
  - name: conformance-container
    image: registry.k8s.io/conformance-amd64:v1.31.2 #EDIT THIS FOR YOUR CLUSTER
    imagePullPolicy: IfNotPresent
    env:
    - name: E2E_FOCUS
      value: "\\[Conformance\\]"
    - name: E2E_SKIP
      value: ""
    - name: E2E_PROVIDER
      value: "skeleton"
    - name: E2E_PARALLEL
      value: "false"
    - name: E2E_VERBOSITY
      value: "4"
    volumeMounts:
    - name: output-volume
      mountPath: /tmp/results
  volumes:
  - name: output-volume
    hostPath:
      path: /tmp/results
  restartPolicy: Never
  serviceAccountName: conformance-serviceaccount

Testing

Checklist:

  1. If your PR changes anything on or related to Jenkins, run it pointing to your branch to make sure it's okay.
    not yet

  2. Verify code lint; we should not have errors.

  3. Update the documentation if needed.

  4. Update makefile and docker run if adding new tests.

  5. Run your tests at least 4 times with all configurations needed and possible.

  6. If needed test with different os types.

Linked Issues

Further Comments

@VestigeJ
Copy link
Contributor Author

I'll be running golangci-lint run a lot more before creating PRs in the future.... Apologies

cluster.Config.Product) + " https://127.0.0.1:6443/healthz",
}

servers, err := shared.GetNodesByRoles("control-plane")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: servers -> cpNodes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

controlPlaneNodes is my replacement string again long for comprehension considering it shouldn't be a string that is typed often but that is read more than re-typed.

@mdrahman-suse
Copy link
Contributor

I'll be running golangci-lint run a lot more before creating PRs in the future.... Apologies

No worries, you can just run make pre-commit before pushing the changes

sonobuoyVersion := customflag.ServiceFlag.External.SonobuoyVersion
err := shared.SonobuoyMixedOS("install", sonobuoyVersion)
// TestDisplayClusterDetails used to display cluster details.
func TestDisplayClusterDetails() {
Copy link
Contributor

@ShylajaDevadiga ShylajaDevadiga Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we not using this here? https://github.com/rancher/distros-test-framework/blob/main/pkg/template/helper.go#L79
Update path is all tests thats using this method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is still exposed publicly from the conformance file

@VestigeJ VestigeJ closed this Jan 15, 2025
@VestigeJ VestigeJ reopened this Jan 15, 2025
fmt.Println("serverVersion: ", strings.Split(serverVersion, "\n"))
fmt.Println("re:", re)
match := re.FindStringSubmatch(serverVersion)
fmt.Println("match: ", match)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to print use logs please in all those println

Comment on lines +32 to +41
if deleteWorkload {
cmd = "sonobuoy delete --all --wait --kubeconfig=" + shared.KubeConfigFile
_, err = shared.RunCommandHost(cmd)
Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd)
err = shared.InstallSonobuoy("delete")
if err != nil {
GinkgoT().Errorf("error: %v", err)
return
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can probably re-use cleanupTests func here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially some months ago I specifically didn't want to change the existing mixedOS test functionality, but good call out now.

Comment on lines +23 to +30
cmd = "sonobuoy retrieve --kubeconfig=" + shared.KubeConfigFile
testResultTar, err := shared.RunCommandHost(cmd)
Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd)

cmd = "sonobuoy results " + testResultTar
res, err = shared.RunCommandHost(cmd)
Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd)
Expect(res).Should(ContainSubstring("Plugin: mixed-workload-e2e\nStatus: passed\n"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can probably re-use getResults and parseResults func here

Copy link
Contributor

@mdrahman-suse mdrahman-suse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments, else LGTM... also needs rebasing

@VestigeJ VestigeJ force-pushed the sonobuoy branch 4 times, most recently from b615b22 to 5dffd50 Compare February 18, 2025 17:53
}

os.Exit(m.Run())
os.Exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code line is unreachable

@VestigeJ VestigeJ closed this Feb 26, 2025
@VestigeJ VestigeJ deleted the sonobuoy branch February 26, 2025 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants